<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function Person(name1, age1) {
      this.name = name1;
      this.age = age1;
      // 1. 如果值是一个对象
      this.permission = ["user", "salary", "vacation"];
    }
    Person.prototype.say = function () {
      console.log("人类会说话");
    }

    function Student(theCno, name2, age2) {
      this.cno = theCno;
      // 3. 解决方式, 拷贝一份对象给它自己
      Person.call(this, name2, age2);
    }
    // 原型属性继承
    Student.prototype = new Person();

    Student.prototype.eat = function () {
      console.log('吃东西');
    }




    var stu = new Student("114期", "小传", 39);
    stu.permission.pop();
    stu.say()
    stu.eat()
    var stu2 = new Student("114期", "孙悟空", 30);
    stu2.say()
    stu.eat()
    console.log('stu2', stu2);
    console.log('stu', stu);

  </script>
</body>

</html>